//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================


//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - S+S Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using Microsoft.Practices.SmartClient.DisconnectedAgent;
using System;
using Shp.Runtime.Contract;
using LitwareHR.Infrastructure.Interface;

namespace LitwareHR.PublicApp.WinUX.DSA.Secure.DataModelService
{
    // Generated code for the web service.
    // Use this proxy to make requests to the service when working in an application that is occasionally connected
    public class Callback : CallbackBase
    {
        #region Event Handler

        #region UpdateViewDef

        public static event EventHandler<EventArgs<object[]>> UpdateViewDefReturn;
        public static event EventHandler<EventArgs<Exception>> UpdateViewDefException;

        #endregion UpdateViewDef

        #region UpdateEntityDef

        public static event EventHandler<EventArgs<object[]>> UpdateEntityDefReturn;
        public static event EventHandler<EventArgs<Exception>> UpdateEntityDefException;

        #endregion UpdateEntityDef

        #region AddInstance

        public static event EventHandler<AddInstanceEventArgs> AddInstanceReturn;
        public static event EventHandler<EventArgs<Exception>> AddInstanceException;

        #endregion AddInstance

        #endregion

        #region UpdateViewDef

        public override void OnUpdateViewDefReturn(Request request, object[] parameters)
        {
            if (UpdateViewDefReturn != null)
            {
                UpdateViewDefReturn(this, new EventArgs<object[]>(parameters));
            }
        }

        public override OnExceptionAction OnUpdateViewDefException(Request request, Exception ex)
        {
            if (UpdateViewDefException != null)
            {
                UpdateViewDefException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
        }

        #endregion UpdateViewDef

        #region UpdateEntityDef

        public override void OnUpdateEntityDefReturn(Request request, object[] parameters)
        {
            if (UpdateEntityDefReturn != null)
            {
                UpdateEntityDefReturn(this, new EventArgs<object[]>(parameters));
            }
        }

        public override OnExceptionAction OnUpdateEntityDefException(Request request, Exception ex)
        {
            if (UpdateEntityDefException != null)
            {
                UpdateEntityDefException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
        }

        #endregion UpdateEntityDef

        #region AddInstance

        public override void OnAddInstanceReturn(Request request, object[] parameters, Guid returnValue)
        {
            if (AddInstanceReturn != null)
            {
                AddInstanceReturn(this, new AddInstanceEventArgs(returnValue, parameters));
            }
        }

        public override OnExceptionAction OnAddInstanceException(Request request, Exception ex)
        {
            if (AddInstanceException != null)
            {
                AddInstanceException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
        }

        #endregion AddInstance

    }

    public class AddInstanceEventArgs : EventArgs
    {
        private Guid id;

        public Guid Id
        {
            get { return id; }
            set { id = value; }
        }
        
        private object[] parameters = null;

        public object[] Parameters
        {
            get { return parameters; }
            set { parameters = value; }
        }

        public AddInstanceEventArgs(Guid id, object[] parameters)
        {
            this.id = id;
            this.parameters = parameters;
        }
    }
}
